package com.yingside.collection.book;

import java.util.*;

public class Test {
    public static void main(String[] args) {
        //城市中有三个不同的图书馆，每个图书馆中都存放有不同的书籍
        //图书馆基本信息：id，libraname，address
        //书籍基本属性 id，bookname，author，price
        //虚拟化成代码

        //1、不同的图书馆中，保存不同的书籍，把这个虚拟化为代码实现
        //实现方式不限制，提示：注意图书馆和书籍的关系，打印不同图书馆中，不同的书籍信息

        //2、往不同的图书馆中放入书籍，同一图书馆中的书籍不能重复(注意：不单单是对象不能重复，图书的id也不能重复)

        //3、选择某一个图书馆中的所有书籍，这些书籍按照书籍价格进行排序，并算出书籍的总金额


        Book b1 = new Book(1,"斗破苍穹","天蚕土豆",30);
        Book b6 = new Book(1,"斗破苍穹","天蚕土豆",30);
        Book b2 = new Book(2,"星辰变","番茄",10);
        Book b3 = new Book(3,"诡秘之主","乌贼",20);
        Book b4 = new Book(4,"斗罗大陆","三少",70);
        Book b5 = new Book(5,"肾虚","辰东",80);

        Set<Book> bs1 = new TreeSet<>();
        bs1.add(b1);bs1.add(b2);bs1.add(b6);

        Set<Book> bs2 = new TreeSet<>();
        bs2.add(b3);

        Set<Book> bs3 = new TreeSet<>();
        bs3.add(b4);bs3.add(b5);


        Library library1 = new Library();
        library1.setId(1);
        library1.setLibraryName("成都人民图书馆");
        library1.setAddress("武侯区");
        library1.setBooks(bs1);


        Library library2 = new Library();
        library2.setId(2);
        library2.setLibraryName("成都锦江图书馆");
        library2.setAddress("锦江区");
        library2.setBooks(bs2);

        Library library3 = new Library();
        library3.setId(3);
        library3.setLibraryName("成都三国图书馆");
        library3.setAddress("武侯区");
        library3.setBooks(bs3);


//        System.out.println(library1.getId());
//        System.out.println(library1.getLibraryName());
//        System.out.println(library1.getAddress());
//        for (Book book:library1.getBooks()) {
//            System.out.println("book = " + book);
//        }

        List<Library> libraries = new ArrayList<>();
        libraries.add(library1);
        libraries.add(library2);
        libraries.add(library3);

        int count = 1;
        for (Library library:libraries) {
            System.out.println("第"+count+"座图书管");
            System.out.println(library.getId());
            System.out.println(library.getLibraryName());
            System.out.println(library.getAddress());
            for (Book book:library.getBooks()) {
                System.out.println("book = " + book);
            }
            count ++;
        }
    }
}
